﻿Public Class ctrPhanQuyen

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        frmMain.TabControl1.TabPages.Remove(frmMain.TabControl1.SelectedTab)
    End Sub

    Private Sub checkBox_Load()
        If (cmbQuyen.SelectedIndex() = 0) Then
            clbNhanVien.SetItemChecked(0, True) 'Tiep nhan
            clbNhanVien.SetItemChecked(1, True) 'Phan cong
            clbNhanVien.SetItemChecked(2, True) 'chinh sua
            clbNhanVien.SetItemChecked(3, True) 'chinh sua bc, cv
            clbNhanVien.SetItemChecked(4, True) 'tra cuu

            clbBan.SetItemChecked(0, True) 'chinh sua
            clbBan.SetItemChecked(1, True) 'dat ban
            clbBan.SetItemChecked(2, True) 'tra cuu

            clbThucDon.SetItemChecked(0, True) 'goi mon
            clbThucDon.SetItemChecked(1, True) 'chinh sua
            clbThucDon.SetItemChecked(2, True) 'tra cuu

            clbHoaDon.SetItemChecked(0, True) 'thanh toan
            clbHoaDon.SetItemChecked(1, True) 'tra cuu

            clbDuLieu.SetItemChecked(0, False) 'ket noi
            clbDuLieu.SetItemChecked(1, False) 'sao luu
            clbDuLieu.SetItemChecked(2, False) 'truy xuat

            clbHeThong.SetItemChecked(0, False) 'phan quyen
            clbHeThong.SetItemChecked(1, False) 'tai khoan
            clbHeThong.SetItemChecked(2, False) 'cau hinh

            clbThongTin.SetItemChecked(0, True) 'gioi thieu
            clbThongTin.SetItemChecked(1, True) 'huong dan
        Else
            clbNhanVien.SetItemChecked(0, False) 'Tiep nhan
            clbNhanVien.SetItemChecked(1, False) 'Phan cong
            clbNhanVien.SetItemChecked(2, False) 'chinh sua
            clbNhanVien.SetItemChecked(3, False) 'chinh sua bc, cv
            clbNhanVien.SetItemChecked(4, True) 'tra cuu

            clbBan.SetItemChecked(0, False) 'chinh sua
            clbBan.SetItemChecked(1, True) 'dat ban
            clbBan.SetItemChecked(2, True) 'tra cuu

            clbThucDon.SetItemChecked(0, True) 'goi mon
            clbThucDon.SetItemChecked(1, False) 'chinh sua
            clbThucDon.SetItemChecked(2, True) 'tra cuu

            clbHoaDon.SetItemChecked(0, True) 'thanh toan
            clbHoaDon.SetItemChecked(1, True) 'tra cuu

            clbDuLieu.SetItemChecked(0, False) 'ket noi
            clbDuLieu.SetItemChecked(1, False) 'sao luu
            clbDuLieu.SetItemChecked(2, False) 'truy xuat

            clbHeThong.SetItemChecked(0, False) 'phan quyen
            clbHeThong.SetItemChecked(1, False) 'tai khoan
            clbHeThong.SetItemChecked(2, False) 'cau hinh

            clbThongTin.SetItemChecked(0, True) 'gioi thieu
            clbThongTin.SetItemChecked(1, True) 'huong dan
        End If
    End Sub

    Private Sub cmbQuyen_Load()
        cmbQuyen.Items.Insert(0, "Quản lý")
        cmbQuyen.Items.Insert(1, "Nhân viên")
        cmbQuyen.SelectedIndex() = 0
    End Sub

    Private Sub ctrPhanQuyen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmbQuyen_Load()
        checkBox_Load()
    End Sub

    Private Sub cmbQuyen_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbQuyen.SelectedIndexChanged
        checkBox_Load()
    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        MessageBox.Show("Đã lưu lại phân quyền")
    End Sub
End Class
